package com.yupi.springbootinit.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.springbootinit.mapper.UserMapper;
import model.entity.User;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import service.InnerUserService;

import javax.annotation.Resource;

/**
 * @author 25169
 */
@Service(version = "${dubbo.service.version}")
public class InnerUserServiceImpl implements InnerUserService {

    private static final Logger logger = LoggerFactory.getLogger(InnerUserServiceImpl.class);
    @Resource
    private UserMapper userMapper;
    @Override
    public User getInvokeUser(String accessKey) {
        if(StringUtils.isAnyBlank(accessKey)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        LambdaQueryWrapper<User> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getAccessKey,accessKey);
        logger.info("User+++++++++++{}",userMapper.selectOne(queryWrapper));
        return  userMapper.selectOne(queryWrapper);

    }
}
